home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / graphicgems4.lha / GemsIV / dyn_range / test_hdp.c < prev   
Encoding:
C/C++ Source or Header  |  1995-02-06  |  1.2 KB  |  48 lines

  1. /*
  2. ** TEST_HDP.C : Simple testing program for the HDP routines
  3. */
  4.  
  5. #include "hdp.h"
  6.  
  7. void main (void)
  8. {
  9.     realcolor RealColor;
  10.     bytecolor ByteColor;
  11.     real LoVal, HiVal, Bright;
  12.     int  Index, NbTst, NbVal;
  13.  
  14. /* Dynamic range of 4000 (try also larger or smaller values) */
  15.   LoVal = 0.25;
  16.   HiVal = 1000.0;
  17.  
  18. /* Memory for encoding LUT = 8 Kbytes */
  19.   NbVal = 8192;
  20.  
  21. /* Construction of the encoding LUT */
  22.   init_HDP_encode (LoVal, HiVal, NbVal);
  23.  
  24. /* No brightness modification (try also negative and positive values) */
  25.   Bright = 0.0;
  26.  
  27. /* Construction of the decoding LUT */
  28.   init_HDP_decode (LoVal, HiVal, Bright);
  29.  
  30. /*
  31.    Test NbTst sample values (ranging from 0 to HiVal)
  32.    before and after a coding/decoding sequence
  33. */
  34.   NbTst = HiVal / LoVal;
  35.   for (Index = 0; Index <= NbTst; Index++) {
  36.     RealColor[0] = RealColor[1] = RealColor[2] = Index * HiVal / NbTst;
  37.     printf ("Before = %.2f\t", RealColor[0]);
  38.     HDP_ENCODE (RealColor, ByteColor);
  39.     printf ("Coded value = %d\t", ByteColor[0]);
  40.     HDP_DECODE (ByteColor, RealColor);
  41.     printf ("After = %.2f\n", RealColor[0]);
  42.   }
  43.  
  44. /* Destruction of the look-up tables */
  45.     exit_HDP_encode ();
  46.     exit_HDP_decode ();
  47. }
  48.